package com.kuaifawu.lwnlawyerclient.LWNNetwork;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;

import com.google.android.gms.wearable.MessageApi;
import com.kuaifawu.lwnlawyerclient.Model.LWNModel_user;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.http.RequestParams;

import java.io.File;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

/**
 * Created by zhangminglei on 15/1/7.
 */

public class LWNNetworkCenter {
    private static String LWNSecret_key = "9e304d4e8df1b74cfa009913198428ae";
    private static String Version = "1.0.0";
    private static String Model = "android";

     //private static String LWNBaseUrl_GET = "http://api.kfw.test/?";
    //private static String LWNBaseUrl_GET = "http://api.kfw.test/lawyer/";
   private static String LWNBaseUrl_GET = "http://api.test.kuaifawu.com/lawyer/";
    //private static String LWNBaseUrl_GET = "http://api.kuaifawu.com/?";

   // private static String LWNNEWBaseUrl_GET = "http://api.kfw.test/lawyer/";

  // public static String LWNBaseUrl_POST = "http://api.kfw.test/";//LWNBaseUrl_POST
    public static String LWNBaseUrl_POST = "http://api.test.kuaifawu.com/lawyer/";
    //private static String LWNBaseUrl_POST = "http://api.kuaifawu.com/";

   // private static String LWNBaseQrCodeURL = "http://api.kfw.test/login/";
   private static String LWNBaseQrCodeURL = "http://api.test.kuaifawu.com/login/";
    //private static String LWNBaseQrCodeURL = "http://api.kuaifawu.com/login/";

    //public static String LWNProtocolURL = "http://api.kuaifawu.com/Index/agreement";

    private static LWNNetworkCenter ourInstance = new LWNNetworkCenter();
    private static HttpUtils httpInstance = new HttpUtils(10000);

    public static LWNNetworkCenter getInstance() {
        return ourInstance;
    }

    private LWNNetworkCenter() {

    }

    public HttpUtils getUtils(){
        return httpInstance;
    }

    /**
     * @param32位MD5加密
     * @return
     */
    public static String getMd5Value(String sSecret) {
        try {
            MessageDigest bmd5 = MessageDigest.getInstance("MD5");
            bmd5.update(sSecret.getBytes());
            int i;
            StringBuffer buf = new StringBuffer();
            byte[] b = bmd5.digest();
            for (int offset = 0; offset < b.length; offset++) {
                i = b[offset];
                if (i < 0)
                    i += 256;
                if (i < 16)
                    buf.append("0");
                buf.append(Integer.toHexString(i));
            }
            return buf.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return "";
    }

    /**
     * @param排序加密
     * @return加密结果
     */
    private String sortArray(ArrayList<String>list_data) {
        Comparator<String> itemComparator = new Comparator<String>() {
            public int compare(String string_one, String string_two) {
                return string_one.compareTo(string_two);
            }
        };
        Collections.sort(list_data, itemComparator);

        StringBuffer reslut = new StringBuffer();

        for (int i = 0; i<list_data.size(); i++){
            reslut = reslut.append(list_data.get(i));
        }

        reslut = reslut.append(LWNSecret_key);
        //System.out.println("排序是:" + reslut.toString());

        String string_md5 = getMd5Value(reslut.toString());
        return string_md5;
    }

    /**
     * 登录URL
     * @param phone 手机号
     * @param mm    密码
     */
    public String getLogin(String phone, String mm ,Activity activity_save) {
        String udid = LWNModel_user.getInstance().getString_deviceToken(activity_save);
        if(udid == null){
            udid = "";
        }
        ArrayList<String> array_sort = new ArrayList<String>();
        array_sort.add(phone);
        array_sort.add(mm);
        array_sort.add(udid);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "lawylogin?" + "mobile=" + phone + "&userpass=" + mm + "&udid=" + udid + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * 退出登录URL
     */
    //
    public String getLoginOut(Activity activity_save) {
        String uid =LWNModel_user.getInstance().getString_uid(activity_save);
        if(uid == null){
            uid = "";
        }
        ArrayList<String> array_sort = new ArrayList<String>();
        array_sort.add(uid);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "/logout?" +"id="+uid + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }


    /**
     * 获取验证码URL
     * @param phone 手机号
     */
    public String getSendCode(String phone) {
        ArrayList<String> array_sort = new ArrayList<String>();
        array_sort.add(phone);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "sendcode?" + "mobile=" + phone  + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }


    /**
     * 获取验证码URL
     * @param phone 手机号
     */
    public String verifySendCode(String phone,String code) {
        ArrayList<String> array_sort = new ArrayList<String>();
        array_sort.add(phone);
        array_sort.add(code);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "testcode?" + "mobile=" + phone  +"&code="+code+ "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }
    /**
     * 获取验证码URL
     * @para mnn 密码
     */
    public String finishMMSetting(String mm,Activity activity_save,String id) {
        String udid = LWNModel_user.getInstance().getString_deviceToken(activity_save);

        if(udid == null){
            udid = "";
        }
        ArrayList<String> array_sort = new ArrayList<String>();
        array_sort.add(id);
        array_sort.add(mm);
        array_sort.add(udid);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "setlawypassword?"  +"id="+id+"&userpass="+ mm+"&udid="+udid +"&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }


    /**
     * @param @获取我擅长的列表
     * @param start 开始条数
     * @param count 请求条数
     * @return
     */
    public String getMyGoodAtList(String start, String count ,Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if(uid == null ){
            uid = "";

        }
        if(token == null){
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(start);
        array_sort.add(count);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "goodatquestionlist?id=" + uid + "&start=" + start + "&displaynum=" + count + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * @param @获取我擅长的列表
     * @param start 开始条数
     * @param count 请求条数
     * @return
     */
    public String getAllList(String start, String count ,Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if(uid == null || token == null){
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(start);
        array_sort.add(count);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "allquestionlist?id=" + uid + "&start=" + start + "&displaynum=" + count + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }







    /**
     * @param @获取我回答过的列表
     * @param start     开始条数
     * @param count     请求条数
     * @return
     */
    public String getMyQusetion(String start, String count, Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(start);
        array_sort.add(count);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "getanswinfolawy?id=" + uid + "&start=" + start + "&displaynum=" + count + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * @param @问题id
     * @param @activity_save  寄存activity
     * @return 返回链接
     */
    public String getQuestionDetail(String question_id, Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(question_id);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "questioninfolawy?id=" + uid + "&question_id=" + question_id  + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * 回答问题
     * @param @message 回答内容
     * @param @activity_save
     * @return
     */
    public RequestParams sendMessage(String message, String question_id,Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(question_id);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);

        RequestParams params = new RequestParams();
        params.addBodyParameter("id", uid);
        params.addBodyParameter("question_id", question_id);
        params.addBodyParameter("content", message);
        params.addBodyParameter("content_img", "");
        params.addBodyParameter("content_speech", "");
        params.addBodyParameter("token", token);
        params.addBodyParameter("src", Model);
        params.addBodyParameter("edition", Version);
        params.addBodyParameter("sig", stringing_sign);

        return params;
    }

    /**
     * @param  @获取通知未读数量
     */
    public String getUnreadMessage(Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "selectlawyunread?id=" + uid + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * @param @获取消息中心动态
     */
    public String getDongtaiMessage(String start, String count, Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(start);
        array_sort.add(count);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "questionnoticelist?id=" + uid + "&start=" + start + "&displaynum=" + count + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * @param @获取系统消息
     */
    public String getSystemMessage(String start, String count, Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(start);
        array_sort.add(count);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "systemnoticelist?id=" + uid + "&start=" + start + "&displaynum=" + count + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * @param @更新问题动态未读数量
     */
    public String uploadQuestionUnreadCount(String qid, Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        String unread="0";
        ArrayList<String> array_sort = new ArrayList<String>();
        //array_sort.add(unread);
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(qid);
        array_sort.add(unread);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "updatelawyunread?id=" + uid + "&question_id=" + qid+"&unread="+unread + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * @param @更新系统通知未读数量
     */
    public String uploadSystemUnreadCount(String qid, Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(qid);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "updatenoticeunreadl?id=" + uid + "&n_id=" + qid + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * @param @清空已读信息
     * type - 0-问题通知
     *        1-系统通知
     */
    public String cleanUnreadCount(String type, Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(type);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "deleteallydinfo?id=" + uid + "&type=" + type + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }


    /**
     * @param @删除消息
     * type - 0-问题通知
     *        1-系统通知
     */
    public String deletMessage(String n_id, Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(n_id);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseUrl_GET + "deletenoticeinfo?id=" + uid + "&n_id=" + n_id + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }





    /**
     * @param @获取律师信息
     */
    public String getLawyerInfo(Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
       // array_sort.add("lawywithinfo");
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(token);
        array_sort.add(Model);//http://api.kfw.test/lawyer/
        array_sort.add(Version);//　　http://api.kfw.test/lawyer/lawywithinfo?id=id&token=token&src=src&edition=edition&sig=sig
        String stringing_sign = sortArray(array_sort);
        //String string_url = LWNBaseUrl_GET + "method=lawywithinfo&id=" + uid + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        String string_url = LWNBaseUrl_GET + "lawywithinfo?id=" + uid + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * @param @获取成长信息
     */
    public String getGrowInfo(Activity activity_save) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        //String string_url = LWNBaseUrl_GET + "method=lawywithinfo&id=" + uid + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        String string_url = LWNBaseUrl_GET + "mygrowuplawy?id=" + uid + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;//LWNNEWBaseUrl_GET
    }

    /**
     *
     * @param activity_save
     * @param content//编辑的是签名内容还是简介内容
     * @return
     */
    public RequestParams getSavesigntrue(Activity activity_save,String content,String contenKey){//http://api.kfw.test/lawyer/updatelawysignatu
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);

        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        RequestParams params = new RequestParams();
        params.addBodyParameter("id", uid);
        params.addBodyParameter(contenKey,content);
        params.addBodyParameter("token", token);
        params.addBodyParameter("src", Model);
        params.addBodyParameter("edition", Version);
        params.addBodyParameter("sig", stringing_sign);
        return params;
    }


    /**
     *
     * @param activity_save
     * @param imagedir//头像更改
     * @return
     */
    public RequestParams updePhoto(Activity activity_save,String imagedir){//http://api.kfw.test/lawyer/updatelawysignatu
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);

        ArrayList<String> array_sort = new ArrayList<String>();
        if (uid == null || token == null) {
            uid = "";
            token = "";
        }
        array_sort.add(uid);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        RequestParams params = new RequestParams();
        params.addBodyParameter("id", uid);
        params.addBodyParameter("headsrc", new File(imagedir));
        params.addBodyParameter("token", token);
        params.addBodyParameter("src", Model);
        params.addBodyParameter("edition", Version);
        params.addBodyParameter("sig", stringing_sign);
        return params;
    }


    /**
     *扫码是否成功
     * @param stu
     * @param code
     * @param activity_save
     * @return
     */

    public String getCode(String stu, String code, Activity activity_save) {
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();

        array_sort.add(stu);
        array_sort.add(code);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseQrCodeURL +  "isqrcode?stu=" + stu + "&code=" + code  + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * 确认是否要登录网页版
     * @param code
     * @param activity_save
     * @return
     */
    public String getLogn( String code, Activity activity_save) {
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        String id = LWNModel_user.getInstance().getString_uid(activity_save);
        array_sort.add(id);
        array_sort.add(code);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseQrCodeURL +  "loginpro?id=" + id + "&code=" + code + "&token=" + token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * 取消网页登录
     * @param activity_save
     * @return
     */
    public String getCancelWebLogn( Activity activity_save) {
        ArrayList<String> array_sort = new ArrayList<String>();
        String id = LWNModel_user.getInstance().getString_uid(activity_save);
        array_sort.add(id);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseQrCodeURL +  "outlogin?id=" + id  + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * 判断是否已经登录网页版
     * @param activity_save
     * @return
     */
    public String getIsWebLogn( Activity activity_save) {
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        ArrayList<String> array_sort = new ArrayList<String>();
        String id = LWNModel_user.getInstance().getString_uid(activity_save);
        if (id == null || token == null) {
            id = "";
            token = "";
        }
        array_sort.add(id);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);
        String string_url = LWNBaseQrCodeURL +  "isloginstu?id=" + id +"&token="+token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return string_url;
    }

    /**
     * 举报页面
     * @param data
     * @param activity_save
     * @param question_id
     * @return
     */
//http://api.kfw.test/lawyer/lawyReport?id=1&question_id=1&report=举报&token=token
    public RequestParams getReport(String data,Activity activity_save,String question_id) {
        String uid = LWNModel_user.getInstance().getString_uid(activity_save);
        String token = LWNModel_user.getInstance().getString_token(activity_save);
        if(uid == null){
            uid = "";
        }
        ArrayList<String> array_sort = new ArrayList<String>();

        array_sort.add(uid);
        array_sort.add(question_id);// array_sort.add(data);
        array_sort.add(token);
        array_sort.add(Model);
        array_sort.add(Version);
        String stringing_sign = sortArray(array_sort);

        RequestParams params = new RequestParams();
        params.addBodyParameter("id", uid);
        params.addBodyParameter("question_id",question_id);
        params.addBodyParameter("token", token);
        params.addBodyParameter("report", data);
        params.addBodyParameter("src", Model);
        params.addBodyParameter("edition", Version);
        params.addBodyParameter("sig", stringing_sign);
       // String string_url = LWNBaseUrl_GET + "lawyReport?" + "id=" + udid + "&question_id=" + question_id + "&report=" + data+"&token="+token + "&src=" + Model + "&edition=" + Version + "&sig=" + stringing_sign;
        return params;
    }

    /**
     * 判断网络的连接
     */
    private ConnectivityManager manager;
    public  boolean checkNetworkState(Context context) {
        boolean flag = false;
        //得到网络连接信息
        if(context!=null){
            manager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
            //去进行判断网络是否连接
            if (manager.getActiveNetworkInfo() != null) {
                flag = manager.getActiveNetworkInfo().isAvailable();
            }
        }

//        if (!flag) {
//            //setNetwork();
//        } else {
//            // isNetworkAvailable();
//        }

        return flag;
    }
}
